package read.niit.dao

import java.util.Properties

import org.apache.spark.sql.Dataset
import read.niit.bean.{Reader, ReaderWithRecommendations}
import read.niit.util.SparkUtil

class BatchReaderDao {

  private val spark = SparkUtil.takeSpark()
  import spark.implicits._

  //获取reader表中的数据
  def getReaderData(): Dataset[ReaderWithRecommendations] ={
    val props = new Properties()
    props.setProperty("user","root")
    props.setProperty("password","Niit@123")
    val allInfoDS:Dataset[ReaderWithRecommendations] =  spark.read.jdbc(
      "jdbc:mysql://node1:3306/BD2?useUnicode=true&characterEncoding=utf8",
      "reader",
      props
    ).as[ReaderWithRecommendations]
    //返回值
    allInfoDS
  }

}